﻿//https://leetcode.cn/problems/two-sum/?envType=study-plan-v2&envId=top-100-liked

class Solution {
public:
    vector<int> twoSum(vector<int>& nums, int target)
    {
        int n = nums.size();
        unordered_map<int, int> hash(n);
        for (int i = 0; i < n; i++)
        {
            int x = target - nums[i];
            if (hash.count(x)) return { hash[x],i };
            hash[nums[i]] = i;
        }

        return { -1,-1 };

    }
};